// hyb_yl/krecovery/pages/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tab_index: 0,
    tabList: ['电话问诊', '视频问诊', '挂号预约'],
    colorBg: '#50c582',
    timeLists: [{
      title: "上午",
      icon:"",
      list: [{
        state:true,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      }]
    },{
      title: "下午",
      icon:"",
      list: [{
        state:true,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      }]
    },{
      title: "晚上",
      icon:"",
      list: [{
        state:true,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      },{
        state:false,
        time:"09:00-09:30"
      }]
    }]
  },
  tab_choose: function (e) {
    var index = e.currentTarget.dataset.index;
    this.setData({
      tab_index: index
    })
  },

  time_choose:function(e){
    var oid=e.currentTarget.dataset.oid;
    var index=e.currentTarget.dataset.index;
    var timeLists=this.data.timeLists;
    timeLists[oid].list[index].state=!timeLists[oid].list[index].state
    console.log(timeLists[oid].list[index].state)
    this.setData({
      timeLists:timeLists
    })
  },
  choose_all:function(e){
    var timeLists=this.data.timeLists;
    for(var i=0;i<timeLists.length;i++){
      for(var j=0;j<timeLists[i].list.length;j++){
        timeLists[i].list[j].state=true
      }
    }
    this.setData({
      timeLists
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var date = new Date()
    console.log(date)
    var y = date.getFullYear()
    var m = date.getMonth() + 1
    var r = date.getDate()

    var ms = m;
    var rs = r;
    if (ms < 10) {
      ms = "0" + ms;
    }
    if (rs < 10) {
      rs = "0" + rs;
    }
    y + '/' + m + '/' + r
    this.setData({
      spot: [y + '/' + m + '/' + r],
      time: y + '-' + ms + '-' + rs
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})